class Shooter {
   
	final static byte READY       = 0;
   	final static byte EMPTY       = 1;
   	final static byte CHARGING    = 2;
   	final static byte DISCHARGING = 3;

   	public byte power, chargingStep, dischargingStep, maxPower, state;

   	Shooter() {
		init();
   	}

    public void init() {
        state = EMPTY;
    }

    public void activate(byte dischargingValue, byte maxValue) {
        chargingStep = 1;
        dischargingStep = dischargingValue;
        maxPower = maxValue;
        power = maxPower;
        state = READY;
    }

    public void start() {
        state = DISCHARGING;
    }

    public void stop() {
        if (power < maxPower) state = CHARGING;
        else state = READY;
    }

    public boolean isReady() {
        return state == READY;
    }

    public boolean isEmpty() {
        return (state == EMPTY) || (state == CHARGING);
    }

    public void update() {
        switch (state) {
            case CHARGING:
                if (power < maxPower) power += chargingStep;
                else {
                    power = maxPower;
                    state = READY;
                }
            break;
            
            case DISCHARGING:
                if (power > 0) power -= dischargingStep;
                else {
                    power = 0;
                    state = EMPTY;
                }
            break;
        }
    }
}